package cn.tedu.weibo2.controller;

import cn.tedu.weibo2.pojo.dto.CommentDTO;
import cn.tedu.weibo2.pojo.vo.CommentVO;
import cn.tedu.weibo2.pojo.vo.WeiboDetailVO;
import cn.tedu.weibo2.response.JsonResult;
import cn.tedu.weibo2.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.jar.JarEntry;

@Slf4j
@RestController
@RequestMapping("/v1/comment/")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @PostMapping("insert")
    public JsonResult insert(CommentDTO commentDTO){
        log.debug("插入comment的数据:{}",commentDTO);
        commentService.inset(commentDTO);
        return JsonResult.ok();
    }
    @GetMapping("list/{weiboId}")
    public JsonResult list(@PathVariable Long weiboId){
        log.debug("查询评论:微博的id:{}",weiboId);
        List<CommentVO> commentVOList=commentService.list(weiboId);
        log.debug("返回评论:根据微博id查询"+commentVOList);
        return JsonResult.ok(commentVOList);
    }
}
